<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>

<h1>1. out</h1>
<%--
	out.print("Hello world!");
	out.println("Hello world!");
	out.println("Hello world!");
	
	out.flush();// 立即将缓冲区输出
	
	try{
		Thread.sleep(3000);
	}catch(Exception e)
	{
		
	}
	out.println("Hello world!");
	out.println("Hello world!");
--%>



<h1>2. request对象</h1>
<%=request.getRequestURI() 
%><br />
客户端浏览器类型:<%=request.getHeader("User-Agent")
%><br />
<h1>3. response对象</h1>
<%
	//response.setHeader("refresh", "5;url=http://www.baidu.com");
	//response.sendRedirect("http://www.baidu.com");
%>
<h1>4. session对象</h1>
域对象(和某个用户相关)
<%
	session.setAttribute("username", "张三");
%>

<%=session.getAttribute("username") %>

<%
	Integer count=(Integer)session.getAttribute("count");
	if(count==null)
	{
		count=0;
	}
	count++;
	session.setAttribute("count", count);
%>
<%=session.getAttribute("count") %>


<h1>5. application对象</h1>
域对象(全站全局)
<%
	Integer count2=(Integer)application.getAttribute("count");
	if(count2==null)
	{
		count2=0;
	}
	count2++;
	application.setAttribute("count", count2);
%>
<%=application.getAttribute("count") %>



<h1>6. page对象</h1>
当面页面Servlet对象本身


<h1>7. pageContext 上下文对象</h1>
1. 得到其他内置对象<br>
2. 作为域对象(只和当前页面相关)
<%
	Integer count3=(Integer)pageContext.getAttribute("count");
	if(count3==null)
	{
		count3=0;
	}
	count3++;
	pageContext.setAttribute("count", count3);
%>
<%=pageContext.getAttribute("count") %>

</body>
</html>